package com.cristina.attention.utils.enums;

import com.cristina.attention.utils.AttentionCommon;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Objects;

/**
 * 发送的消息类型
 *
 * @author by superman
 */
@Getter
@ToString
@AllArgsConstructor
public enum MessageType {

    /**
     * IM_CHAT -> SYNC   √
     * IM_GROUP -> SYNC √
     * IM_PUSH -> NOTICE √
     * IM_PUSH -> AUTH_CODE   ⍻
     * EMAIL -> NOTICE  √
     * EMAIL -> AUTH_CODE  √
     */
    NOTICE(10, "通知类消息", "notice", "30,40"),
    SYNC(20, "同步聊天记录消息", "sync", "10,20"),
    AUTH_CODE(30, "验证码消息", "auth_code", "40")
    ;

    /**
     * 编码值
     */
    private Integer code;

    /**
     * 描述
     */
    private String description;

    /**
     * 英文标识
     */
    private String codeEn;

    /**
     * 记录需要绑定的 ChannelType Code, 绑定多个用","逗号分隔 "10,20"
     */
    private String channelTypes;

    public static MessageType getEnumByCode(Integer code) {
        MessageType[] values = values();
        for (MessageType value : values) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }
}
